/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.icm.entity;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import merlion.mrp.pmm.entity.FinishedGood;
import merlion.scm.rmpm.entity.RawMaterialInventoryBatch;

/**
 *
 * @author Yuwei
 */
@Entity
public class WarehouseLocation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String binLocation;//location name
    private Double binCapacity;
    private boolean emptyBin;
    private Double storedQty;
    @ManyToOne(targetEntity = FinishedGood.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private FinishedGood batch;
    @ManyToOne(targetEntity = RawMaterialInventoryBatch.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private RawMaterialInventoryBatch rmBatch;
    
    public WarehouseLocation(){
        binLocation = "";
        binCapacity = 100D;//100 cases maximum for 1 bin
        emptyBin = Boolean.TRUE;
        storedQty = 0D;
        batch = new FinishedGood();
        rmBatch = new RawMaterialInventoryBatch();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public FinishedGood getBatch() {
        return batch;
    }

    public void setBatch(FinishedGood batch) {
        this.batch = batch;
    }

    public Double getBinCapacity() {
        return binCapacity;
    }

    public void setBinCapacity(Double binCapacity) {
        this.binCapacity = binCapacity;
    }

    public Double getStoredQty() {
        return storedQty;
    }

    public void setStoredQty(Double storedQty) {
        this.storedQty = storedQty;
    }

    public String getBinLocation() {
        return binLocation;
    }

    public void setBinLocation(String binLocation) {
        this.binLocation = binLocation;
    }

    public boolean isEmptyBin() {
        return emptyBin;
    }

    public void setEmptyBin(boolean emptyBin) {
        this.emptyBin = emptyBin;
    }

    public RawMaterialInventoryBatch getRmBatch() {
        return rmBatch;
    }

    public void setRmBatch(RawMaterialInventoryBatch rmBatch) {
        this.rmBatch = rmBatch;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof WarehouseLocation)) {
            return false;
        }
        WarehouseLocation other = (WarehouseLocation) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.scm.icm.entity.WarehouseLocation[ id=" + id + " ]";
    }
    
}
